<%--
  Created by IntelliJ IDEA.
  User: l
  Date: 2022/5/2
  Time: 18:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@include file="menu.jsp"%>
    <!--/sidebar-->
    <div class="main-wrap">

        <div class="crumb-wrap">
            <div class="crumb-list"><i class="icon-font"></i><a href="admin_index.jsp">首页</a><span class="crumb-step">&gt;</span><span class="crumb-name">用户管理</span></div>
        </div>
        <div class="search-wrap">
            <div class="search-content">
                <form action="/lyq/admin/admin_douserselect" method="get">
                    <table class="search-tab">
                        <tr>
                            <th width="70">关键字:</th>
                            <td><input class="common-text" placeholder="关键字" name="keywords" value="${param.keywords}" id="" type="text"></td>
                            <td><input class="btn btn-primary btn2" name="sub" value="查询" type="submit"></td>
                        </tr>
                    </table>
                </form>
            </div>
        </div>
        <div class="result-wrap">
            <form action="/lyq/admin/admin_douserdel" id="myform" method="post">
                <div class="result-title">
                    <div class="result-list">
                        <a href="admin_useradd.jsp"><i class="icon-font"></i>新增用户</a>
                        <a id="batchDel" href="javascript:delmore('你确定要删除这些用户吗？','myform')"><i class="icon-font"></i>批量删除</a>
                    </div>
                </div>
                <div class="result-content">
                    <table class="result-tab" width="100%">
                        <tr>
                            <th class="tc" width="5%"><input class="allChoose" name="" onclick="selall(this)" type="checkbox"></th>
                            <th>ID</th>
                            <th>姓名</th>
                            <th>性别</th>
                            <th>EMAIL</th>
                            <th>手机号码</th>
                            <th>操作</th>
                        </tr>
<%--                        从DoUserSelect页获取用户数据，进行循环--%>
                        <c:forEach var="u" items="${userlist}">
                        <tr>
                            <td class="tc"><input name="id[]" value="${u.user_name}" type="checkbox"></td>
                            <td>${u.user_id}</td>
                            <td>${u.user_name}</td>
                            <td>${u.user_sex=='1'?'男':'女'}</td>
                            <td>${u.user_email}</td>
                            <td>${u.user_mobile}</td>
                            <td>
                                <a class="link-update" href="admin_touserupdate?id=${u.user_id}&cp=${cpage}&keywords=${param.keywords}">修改</a>
                              <c:if test="${u.user_status==1}" >
                                <a class="link-del" href="javascript:Delete('你确定要删除用户【${u.user_id}】吗？','/lyq/admin/admin_douserdel?id=${u.user_id}&cpage=${cpage}&keywords=${param.keywords}')">删除</a>
                              </c:if>
                            </td>
                        </tr>
                        </c:forEach>
                        <script>
                            //删除一条
                            function Delete(mess,url) {
                                if (confirm(mess)){
                                location.href=url;}
                            }
                            //全选
                            function selall(o) {
                                var a = document.getElementsByName("id[]");
                                for (var i = 0;i<a.length;i++){
                                    a[i].checked = o.checked;
                                }
                            }
                            //删除全部
                            function delmore(mess,formname) {
                                    if(confirm(mess)){
                                        var j = 0;
                                        var form =  document.getElementById(formname);
                                        var a = document.getElementsByName("id[]");
                                        for(var i=0;i<a.length;i++){
                                            if (a[i].checked == true){
                                                j++;
                                            }
                                        }
                                        if (j == 0) {
                                            alert('请进行勾选想删除的项目');
                                        }else {
                                            form.submit();
                                        }}
                            }
                        </script>
                    </table>
                    <div class="list-page">
                        <c:if test="${cpage > 1}">
                            <a href="admin_douserselect?cp=1${searchParams}">首页</a>
                            <a href="admin_douserselect?cp=${cpage-1<1?1:cpage-1}${searchParams}">上一页</a>
                        </c:if>
                        <c:forEach begin="${begin}"  end="${end}" var="i">
                            <c:if test="${cpage == i}">
                                <a href="admin_douserselect?cp=${i}${searchParams}" style="color: #5bb75b">${i}</a>
                            </c:if>
                            <c:if test="${cpage != i}">
                                <a href="admin_douserselect?cp=${i}${searchParams}">${i}</a>
                            </c:if>
                        </c:forEach>
                        共${tsum}条 ，当前 ${cpage}/${tpage} 页
                        <c:if test="${cpage < tpage}">
                            <a href="admin_douserselect?cp=${cpage+1>tpage?tpage:cpage+1}${searchParams}">下一页</a>
                            <a href="admin_douserselect?cp=${tpage}${searchParams}">尾页</a>
                        </c:if>
                    </div>
                </div>
            </form>
        </div>
    </div>
    <!--/main-->
</div>
</body>
</html>